/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package riteservices.model.dao;

import java.util.List;
import java.util.Vector;
import riteservices.model.bean.Notification;
import riteservices.model.bean.User;

/**
 *
 * @author denis
 */
public class NotificationDAO extends GeneralDAO<Notification>{

    public void saveNotificationToUser(int userid,Notification notification){
    ///falta hacer referencia de a quien le van a notificar
        this.add(notification);
    }

    public void saveForMultiplesPassangers(int roundid, Notification notification, Vector<User> passanger){
        
        for(int indice=0;indice<passanger.size();indice++){
        this.add(notification);
        }

    }

    public List<Notification> getPendingNotifications(int userid){
        List<Notification> notifications= search("User_idUser="+userid+" and status=1",Notification.class);
            if(!notifications.isEmpty()){
                return notifications;
            }else{
                return null;
            }
    }
    
    public Notification getById(int id){
        List<Notification> notifications = search("idNotification="+id, Notification.class);
        if(!notifications.isEmpty()){
            return notifications.get(0);
        }else{
            return null;
        }
    }

}
